using System.Collections.Generic;
using HgAdapter;
using HogoLogic.HgFileSystem;

namespace FileSystemView.SelectedFsElements
{
	class SelectedFileList : SelectedFsElement
	{
		List<string> filePathes;
		VersionStatus versionStatus;
		
		public SelectedFileList(List<HgFileInfo> fileInfos)
		{
			filePathes = new List<string>();
			versionStatus = VersionStatus.Empty;
			
			foreach (HgFileInfo fileInfo in fileInfos)
			{
				filePathes.Add(fileInfo.RelativeFullName);
				versionStatus |= fileInfo.VersionStatus;
			}
		}

		public override bool CanBeAdded
		{
			get
			{
				return versionStatus == VersionStatus.Unversioned;
			}
		}

		public override bool CanBeComitted
		{
			get
			{
				return (versionStatus & (VersionStatus.Changed | VersionStatus.Added)) == versionStatus;
			}
		}


		public override string BrackedFileName
		{
			get
			{
				string result = string.Empty;
				
				foreach (string filePath in filePathes)
				{
					result += "\"" + filePath + "\" ";
				}

				return result.Trim();
			}
		}
	}
}
